//
//  XDVisitorViewController.swift
//  weibo
//
//  Created by lucy on 2016/10/23.
//  Copyright © 2016年 com.huashengHuaSheng. All rights reserved.
//

import UIKit

class XDVisitorViewController: UIViewController {

    var isLogin : Bool = XDUserAccountViewModel.shareTools.isLogin
    var visitorView: XDVisitorView?
    
    //MARK-判断是否登录
    override func loadView(){
        if isLogin {
            view = tableView
        }else{
        
            setupVisitorView()
        }
    }
    
    //MARK-懒加载tableView视图
    lazy var tableView : UITableView = UITableView()
    
    

    
    
    //MARK-登录访客视图
    func setupVisitorView(){
    
        visitorView = XDVisitorView()
        setupNavView()
        view = visitorView
        visitorView?.closure = {[weak self] in
            self?.loginClick()

        }

    }
    
    //MARK-注册按钮点击
    @objc private func loginClick(){
        let OAuth = XDOAuthController()
        let OAuthNav = XDNavigationController(rootViewController: OAuth)
        present(OAuthNav, animated: true, completion: nil)
    
//        print("四个按钮被点击了")
    }
    
    //MARK-设置没有登录时导航栏的内容
    private func setupNavView(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(setHighlightImgName: nil,title: "注册", target: self, action: #selector(loginClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(setHighlightImgName: nil,title: "登录", target: self, action: #selector(loginClick))
    
    
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()


    }
    


}
